package com.liar.base;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.List;

/**
 * @author liukai
 * @date 2019/8/27 0027 - 11:10
 */
public class ResultModel {


    private int code;   //返回码 非0即失败
    private String status;
    private String message;
    private List<Object> list; // 返回数据
    private String token;
    private Object data;
    private Long totalPage;
    private boolean registerFlag;

    public boolean isRegisterFlag() {
        return registerFlag;
    }

    public void setRegisterFlag(boolean registerFlag) {
        this.registerFlag = registerFlag;
    }

    public Long getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Long totalPage) {
        this.totalPage = totalPage;
    }

    private int errCode;

    private boolean success;


    public ResultModel() {

    }

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }


    public ResultModel(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public static String success() {
        return success(new HashMap(0));
    }
    public static String success(Object data) {
        return JSON.toJSONString(new ResultModel(0, "解析成功", data));
    }
    public static String failed() {
        return failed("解析失败");
    }
    public static String failed(String msg) {
        return failed(-1, msg);
    }
    public static String failed(int code, String msg) {
        return JSON.toJSONString(new ResultModel(code, msg, new HashMap(0)));
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<Object> getList() {
        return list;
    }

    public void setList(List<Object> list) {
        this.list = list;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public void setData(String data) {
        this.data = data;
    }
}
